package com.mock.action.geography.trustdistrict;

import com.mock.dao.TrustDistrictDao;
import com.mock.dao.TrustRegionDao;
import com.mock.dao.impl.TrustDistrictDaoImp;
import com.mock.dao.impl.TrustRegionDaoImp;
import com.mock.model.TrustDistrict;
import com.mock.model.TrustRegion;
import com.opensymphony.xwork2.ActionSupport;

public class AddTrustDistrictAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		trustRegion = trustRegionDao.getById(trustRegionId);
		return SUCCESS;
	}
	
	public String create() throws Exception {
		TrustDistrict trustDistrict = new TrustDistrict();
		trustDistrict.setTrustRegion(trustRegionDao.getById(trustRegionId));
		trustDistrict.setName(trustDistrictName);
		trustDistrict.setDescription(trustDistrictDescription);
		trustDistrictDao.add(trustDistrict);
		return SUCCESS;
	}
	
	private long trustRegionId = -1L;
	private TrustRegion trustRegion;
	private TrustRegionDao trustRegionDao = new TrustRegionDaoImp();
	private TrustDistrictDao trustDistrictDao = new TrustDistrictDaoImp();
	private String trustDistrictName;
	private String trustDistrictDescription;

	public long getTrustRegionId() {
		return trustRegionId;
	}

	public void setTrustRegionId(long trustRegionId) {
		this.trustRegionId = trustRegionId;
	}

	public TrustRegion getTrustRegion() {
		return trustRegion;
	}

	public void setTrustRegion(TrustRegion trustRegion) {
		this.trustRegion = trustRegion;
	}

	public String getTrustDistrictName() {
		return trustDistrictName;
	}

	public void setTrustDistrictName(String trustDistrictName) {
		this.trustDistrictName = trustDistrictName;
	}

	public String getTrustDistrictDescription() {
		return trustDistrictDescription;
	}

	public void setTrustDistrictDescription(String trustDistrictDescription) {
		this.trustDistrictDescription = trustDistrictDescription;
	}
	
}
